package com.lanou3g.code0417.dirty;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/4/17;
 * Otherwise, I don't know who created it either
 */

public class Main {
    public static void main(String[] args) {
        final Person person = new Person("张三", 18);
        Utils utils = new Utils();
        // 内部类中要使用外部定义的局部变量
        // 该局部变量需要是final类型
        new Thread() {
            @Override
            public void run() {
                utils.updatePerson(person,
                        "李四", 19);
            }
        }.start();



        // 为了演示脏读, 让线程停止500ms,保证
        // 修改了用户名 还没来得及修改年龄呢
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                utils.showPerson(person);
            }
        }).start();


    }
}
